package com.hnxxxy.jfmgr.controller;

import com.github.pagehelper.PageHelper;
import com.hnxxxy.common.AjaxRtnEntity.AjaxRtnEntity;
import com.hnxxxy.common.annotation.LogAnno;
import com.hnxxxy.common.tools.Help;
import com.hnxxxy.common.tools.TableObj;
import com.hnxxxy.jfmgr.pojo.Jf_detail;
import com.hnxxxy.jfmgr.service.JfTestimonialsAuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/jf")
@RestController
@Slf4j
public class JfTestimonialsAuditController {

    @Autowired
    JfTestimonialsAuditService jfTestimonialsAuditService;

    @RequestMapping("/f/testimonialsAudit")
    @LogAnno(description = "奖状审核")
    public TableObj findAllTestimonialsAudit(TableObj tableObj, Jf_detail jf_detail){
        if (jf_detail.getCertificateName() == ""){
            jf_detail.setCertificateName(null);
        }
        if (jf_detail.getEndTime() == ""){
            jf_detail.setEndTime(null);
        }

        PageHelper.startPage(tableObj.getCurr(), tableObj.getNums());
        List<Jf_detail> list = jfTestimonialsAuditService.findAllTestimonialsAudit(jf_detail);
        JfUserTestimonialsStatusController j  = new JfUserTestimonialsStatusController();
        list = j.GetPhoto(list);
        return Help.getPageTableRtn(tableObj,list);
    }

    @RequestMapping("/u/testimonialsAudit")
    @LogAnno(description = "奖状审核操作",descriptiontype = "updateTestimonialsAudit")
    public AjaxRtnEntity updateTestimonialsAudit(@RequestBody Jf_detail jf_detail){
        AjaxRtnEntity ajaxRtnEntity=new AjaxRtnEntity(jfTestimonialsAuditService.updateTestimonialsAudit(jf_detail),"操作成功",null);
        return ajaxRtnEntity;
    }


}
